//
//  Extension+NSAttributedString.swift
//  SHWeibo3
//
//  Created by 余伟康 on 16/7/31.
//  Copyright © 2016年 wangce. All rights reserved.
//

import Foundation

extension NSAttributedString {
    
    // 便利构造函数
    convenience init(emoticon: AYuEmoticon, y: CGFloat, lineHeight: CGFloat) {
        // 文本附件
        let att =  AYuTextAttachment()
        // 赋值
        att.emoticon = emoticon
        // 设置image
        att.image = UIImage.getEmoticonImage(emoticon.path)
        // 记住一定要设置bounds
        att.bounds = CGRect(x: 0, y: y, width: lineHeight, height: lineHeight)
        self.init(attachment: att)
    }
}